﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data;
using System.Data.SqlClient;
namespace DAO
{
    public class DAO_LoaiDT
    {
        public static List<DTO_LoaiDT> selectLoaiDeTai()
        {
            List<DTO_LoaiDT> Listloaidetai = new List<DTO_LoaiDT>();
            try
            {
                string s = "Proc_SelectLoaiDeTai";
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = ketnoi.Cmb();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = s;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                DataTable dt = new DataTable();
                da.Fill(dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DTO_LoaiDT loaidetai = new DTO_LoaiDT();
                    loaidetai.MaLoaiDT = dt.Rows[i]["MaLoaiDT"].ToString();
                    loaidetai.TenloaiDT = dt.Rows[i]["TenloaiDT"].ToString();
                    Listloaidetai.Add(loaidetai);
                }
                ketnoi.Cmb().Close();
                return Listloaidetai;
            }
            catch (Exception ex)
            {
                return Listloaidetai;
            }
        }
    }
}
